var $maskRule = $("#mask-rule"),//规则遮罩层
    $mask = $("#mask"),//红包遮罩层
    $winning = $(".winning"),//红包
    $card = $("#card"),
    $close = $("#close");
//link = false;//判断是否在链接跳转中

//规则
$(".rule").click(function () {
    $maskRule.show();
});
$("#close-rule").click(function () {
    $maskRule.hide();
});

/*中奖信息提示*/
function win(game) {
    //遮罩层显示
    $mask.show();
    $winning.addClass("reback");
    setTimeout(function () {
        $card.addClass("pull");
    }, 500);

    //关闭弹出层,.win
    $("#close,.btn").click(function () {
        $("#close,.btn").unbind();
        //$close.click(function () {
        $mask.hide();
        $winning.removeClass("reback");
        $card.removeClass("pull");
        console.log('领取奖品');
        getgift(game);

    });
    /*$(".win,.btn").click(function () {
        link = true;
    });*/
}
// 领取奖品
function getgift(id) {
    $.get("https://platform.shmixin.cn/usergame/getgift?id=" + id, (res) => {
        if (res.code == 1) {
            console.log('领取奖品成功');
            if (res.data.conins > 0) {
                $(this).blur();
                alert(`已成功领取${res.data.conins}酒币`, "提示");
            } else {
                $(this).blur();
                alert(`谢谢参与`, "提示");
            }
        } else {
            // $mask.hide();
            // $winning.removeClass("reback");
            // $card.removeClass("pull");
            console.log('领取奖品失败');
            $(this).blur();
            alert("领取奖品失败", "提示");
        }
    }
    );
}






